package com.config;


import com.filter.AdminFilter;
import com.filter.LoginFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Set;

/**
 * 权限相关配置
 */
@Configuration
public class AuthConfig {


    /**
     * 注册登录的过滤器bean
     */
    @Bean
    public FilterRegistrationBean loginFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new LoginFilter());
        registration.addUrlPatterns("/user/info","/user/deleteById/*","/user/updateById","/user/changePassword");
        registration.setName("loginFilter");
        registration.setOrder(10);
        return registration;
    }

    /**
     * 注册管理员的过滤器bean
     */
    @Bean
    public FilterRegistrationBean adminFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new AdminFilter());
        registration.addUrlPatterns("/user/pageList","/user/recharge");
        registration.setName("adminFilter");
        registration.setOrder(1);
        return registration;
    }
}
